<?php

//VideoFlow - Joomla Multimedia System for Facebook//

/**
* @ Version 1.1.3
* @ Copyright (C) 2008 - 2010 Kirungi Fred Fideri at http://www.fidsoft.com
* @ VideoFlow is free software
* @ Visit http://www.fidsoft.com for support
* @ Kirungi Fred Fideri and Fidsoft accept no responsibility arising from use of this software 
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
**/
 
// No direct access
 
defined('_JEXEC') or die('Restricted access'); 

global $vparams;

$xparams = &JComponentHelper::getParams( 'com_videoflow' );
$ajaxmode = (int) $xparams->get('ajaxmode', 1);
$tmplname = (string) $xparams->get('tmplname', $vparams->jtemplate);
if (empty($tmplname)) $tmplname = 'listview';
$Itemid = JRequest::getInt('Itemid', $vparams->flowid);
if (empty($Itemid)) $Itemid = ''; else $Itemid = '&Itemid='.$Itemid;
$activeborderc = strtolower((string) $xparams->get('activeborderc', '#E3EBFF'));
$inactiveborderc = strtolower((string) $xparams->get('inactiveborderc', '#000000'));
$fontcolor = (string) $xparams->get('fontcolor');
$vfbgcolor = (string) $xparams->get('vfbgcolor');
$jeffectsclass = (string) $xparams->get('jeffectsclass', '');
$jeffects = (string) $xparams->get('jeffects', '');
$iborders = (int) $xparams->get('iborders', 4);
$borders = (int) $xparams->get('borders', 1);
if (!empty($jeffects)) $iborders = 0;
$showviews = (bool) $xparams->get('showviews', 1);
$showdate = (bool) $xparams->get('showdate', 1);


$vtask = JRequest::getCmd('task');
if ($vtask == 'mysubs') {
$this->data = $this->tabone;
}

//Load template stylesheet

$doc = &JFactory::getDocument();
if (file_exists(JPATH_COMPONENT.'/views/videoflow/tmpl/css/'.$tmplname.'.css')) {
$css = JURI::root().'components/com_videoflow/views/videoflow/tmpl/css/'.$tmplname.'.css';
} else {
$css = JURI::root().'components/com_videoflow/views/videoflow/tmpl/css/listview.css';
}
$doc->addStyleSheet( $css, 'text/css', null, array() );

$iborderc = (string) $xparams->get('iborderc', '#666666');
$bgactive = (string) $xparams->get('bgactive', '#DBDBDB');
$bginactive = (string) $xparams->get('bginactive', '#EDEDED');
 
$css2 = '.vfround, .mod_vflow, .vf_borderc {border-color:'.$iborderc.';}
        .vfmenu_selected, .vf_bgactive {background-color:'.$bgactive.';}
        .vf_bginactive {background-color:'.$bginactive.'}';
$doc->addStyleDeclaration($css2);


/**************************************************************************/

/* 
* You may edit some parts below
*/ 


?>
<table width="100%" cellspacing="0" cellpadding="0" border="0" valign="top" align="center">
<tbody>
<tr><td valign="top">
<div id="vfwrapper" style="background-color:<?php echo $vfbgcolor; ?>; color:<?php echo $fontcolor; ?>;">
<div class="vf_defpadding">
<table width="100%" cellspacing="0" cellpadding="0" border="0" valign="top">
<tbody>
<tr><td valign="top">

<!-- START TOP SECTION --> 
<table width="100%" cellspacing="0" cellpadding="0" border="0" valign="top">
<tbody><tr> <td>

<?php

//Load the menu
if (is_array ($this->menu)){
echo '<div id="vfnavig" class="vfround" style="margin-top:0px; padding-top:0px;">';
foreach ($this->menu as $menu){
  echo $menu;
}
echo '</div>';
}
?>
<?php
     $fbuser = JRequest::getVar ('fbuser');
     if($fbuser || $this->vflow1) {
     echo '<div style="position:relative; height:62px;">'; // Start top banner division
     ?>
     <div class="vf_bgactive" style="position:absolute; left:0px; top: 20px; height:20px; background:<?php echo $bgactive; ?>; width:100%;"></div>
     <div style="position:relative; max-height:62px; padding-left:20px; float:left; z-index:2;"><?php echo $this->vflow1; ?></div>
     <?php
     }
     if ($fbuser) {
     ?>
     <div style="position:relative; margin-top:20px; padding-right:20px; float:right; z-index:3">
     <a href="#" onClick="quitFB()"><?php echo JText::_('Logout'); ?></a>
    </div>
     <div style="margin:5px; position:relative; float:right; z-index:4;">
          <fb:profile-pic class="fb_profile_pic_rendered FB_ElementReady" facebook-logo="true" size="square" uid="<?php echo $fbuser; ?>"></fb:profile-pic>
     </div>
     <div style="position:relative; margin-top:20px; float:right; z-index:5;"><fb:name uid="<?php echo $fbuser; ?>" firstnameonly="true" useyou="false"></fb:name></div>
     <?php
     }
     if ($fbuser || $this->vflow1) echo '</div>'; //End top banner division
 ?>

</td></tr></tbody>
</table>

<!-- END TOP SECTION -->

<?php

/*************** IT IS NOT NECESSARY TO CHANGE THIS PART ****************
**************** BE CAREFUL IF YOU CHOOSE TO MODIFY IT ******************/

if (!empty($this->data) && is_array ($this->data)){
  foreach ($this->data as $data){
      if (empty($data->pixlink)) $data->pixlink = JURI::root().'components/com_videoflow/views/videoflow/tmpl/images/playerview/default_thumbnail.gif';
      if ($vtask == 'mysubs'){
      $data->desc = '';
      if ($showviews) {
      $data->desc .= '<div class="vf_sstats">'.JText::_('Visitors:').' '.$data->visitors.'</div>';
      $data->desc .= '<div class="vf_sstats">'.JText::_('Subscribers:').' '.$data->subscribers.'</div>';
      }
      if ($showdate) $data->desc .= '<div class="vf_sstats">'.JText::_('Date Joined:').' '.$data->join_date.'</div>';
      $thumblink = '<a href="'.JRoute::_('index.php?option=com_videoflow&task=visit&cid='.$data->joomla_id.'&layout='.$tmplname.$Itemid).'">
                    <img width="'.$vparams->thumbwidth.'" height="'.$vparams->thumbheight.'" class="'.$jeffectsclass.'" style="border:'.$iborders.'px solid; border-color:'.$iborderc.';" src="'.$data->pixlink.'"/></a>';      
      $titlelink = '<a href="'.JRoute::_('index.php?option=com_videoflow&task=visit&cid='.$data->joomla_id.'&layout='.$tmplname.$Itemid).'">'.$this->escape($data->title).'</a>';
      } else {
      $thumblink = '<a href="'.JRoute::_('index.php?option=com_videoflow&task=cats&cat='.$data->id.'&sl=categories&layout='.$tmplname.$Itemid).'">
                    <img width="'.$vparams->thumbwidth.'" height="'.$vparams->thumbheight.'" class="'.$jeffectsclass.'" style="border:'.$iborders.'px solid; border-color:'.$iborderc.';" src="'.$data->pixlink.'"/></a>';      
      $titlelink = '<a href="'.JRoute::_('index.php?option=com_videoflow&task=cats&cat='.$data->id.'&sl=categories&layout='.$tmplname.$Itemid).'">'.$this->escape($data->name).'</a>';
      }

       //End default thumbnail and title links

/*****************************************************************************/

// You may edit the parts below to suit your needs. The corresponding css file is css/listview.css
      
?>
<div class="vfbox">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="12"/></td>
<td width="<?php echo $vparams->thumbwidth + 18; ?>" valign="top">
<div style="position: relative;">
<?php echo $thumblink; ?>
</div>
</td>
<td valign="top">
<table width="100%" cellspacing="0" cellpadding="0" style="font-size: 11px; padding-left:10px; padding-right:10px;">
<tbody>
<tr>
<td valign="top" height="20" style="padding-top: 3px; text-align:left;">
<span class="vftitle" style="padding-left:0px;">
<?php echo $titlelink; ?>
</span>
</td>
</tr>
<tr>
<td height="4">
</td>
</tr>
<tr>
<td valign="top" style="text-align:left;">
<div class="vflist3">
<?php echo nl2br($data->desc); ?>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div class="vflist8">
<div class="vf_hsolid_line vf_borderc">
</div>
</div>
</div>
<?php
}
}

?>
</td>
<td class="vfaligntop"><div id="mod_vflow2"><?php echo $this->vflow2; ?></div></td>
</tr></tbody></table>
<div id="vffooter" style="text-align:center;">
<?php
if (!empty($this->pagination)){
echo $this->pagination->getPagesLinks();
echo '&nbsp;&nbsp;';
echo $this->pagination->getPagesCounter();
}
?>
</div>
</div>
</div>
</td></tr></tbody></table>
<script type="text/javascript">
function initFB() {
	FB_RequireFeatures(["XFBML"], function(){
		FB.init("<?php echo $vparams->fbkey; ?>", "<?php echo JURI::root().'components/com_videoflow/fbook/xd_receiver.htm'; ?>");
	});}
function quitFB(){
  FB.Connect.logoutAndRedirect ("<?php echo JRoute::_(JURI::root().'index.php?option=com_videoflow&layout='.$tmplname.$Itemid); ?>");
} 
</script>